const timeReg = /\[(\d{2}):(\d{2})\.(\d{2,3})\]/
export function parseLyric(lrcString) {
  const lyricInfos = []

  const lyricLines = lrcString.split("\n")
  for (const lineString of lyricLines) {
    const res = timeReg.exec(lineString)
    if (!res) continue
    const minute = res[1] * 60 * 1000
    const secend = res[2] * 1000
    const mSecend = res[3].length === 2 ? res[3] * 10 : res[3] * 1
    const time = minute + secend + mSecend
    const text = lineString.replace(timeReg, "")

    lyricInfos.push({ time, text })
  }

  return lyricInfos
}